﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommonFunc;
using DBUtility;

public partial class Manageweb_Manage_NewsClass : System.Web.UI.Page
{
    MODEL.NewsClass MNC = new MODEL.NewsClass();
    MODEL.NewsClass _MNC = new MODEL.NewsClass();

    BLL.NewsClass BNC = new BLL.NewsClass();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["MasterID"] == null)
        {
            Response.Redirect("../Default.aspx");
        }
    }


    #region 类别标题 [格式化]
    protected string FormatClassTitle(object _Title, object _Level)
    {
        return ClassCode.CreateClassListItemText(_Title.ToString(), _Level.ToString());
    }
    #endregion


    #region 是否锁定 [格式化]
    protected string FormatIsLock(object _IsLock)
    {
        Boolean IsLock = Convert.ToBoolean(_IsLock);

        if (IsLock)
        {
            return "已锁定";
        }
        else
        {
            return "已启用";
        }
    }
    #endregion


    #region 锁定切换 [GridView] [Command]
    protected void Btn_IsLock_Command(object sender, CommandEventArgs e)
    {
        try
        {
            MNC.NC_ID = Convert.ToInt32(e.CommandArgument);

            _MNC = BNC.GetDataByID(MNC);

            string SQLstr_IsLock = "UPDATE [NewsClass] SET [NC_IsLock] = NOT [NC_IsLock] ";
            SQLstr_IsLock += "WHERE (NC_ClassCode LIKE '" + _MNC.NC_ClassCode + "%')";

            AccHelper.ExecuteSQL(SQLstr_IsLock);

            LB_AdvancedNewsClass.Text = "修改成功";

            GV_NewsClass.DataBind();
        }
        catch (Exception ex)
        {
            LB_AdvancedNewsClass.Text = ex.Message;
        }
    }
    #endregion
}
